package entity

import "github.com/lab-online/pkg/util"

type LabOption func(*Lab)

func New(opts ...LabOption) LabEntity {
	entity := &Lab{}
	entity.Update(opts...)
	return entity
}

func (l *Lab) Update(opts ...LabOption) {
	for _, opt := range opts {
		opt(l)
	}
}

func WithReportID(id uint) LabOption {
	return func(l *Lab) {
		l.ID = id
	}
}

func WithExperimentID(id uint) LabOption {
	return func(l *Lab) {
		l.ExperimentID = id
	}
}

func WithStatus(status uint) LabOption {
	return func(l *Lab) {
		l.Status = status
	}
}

func RemoveStatusFlag(flag uint) LabOption {
	return func(l *Lab) {
		l.Status = util.BitMaskUnset(l.Status, flag)
	}
}

func AddStatusFlag(flag uint) LabOption {
	return func(l *Lab) {
		l.Status = util.BitMaskSet(l.Status, flag)
	}
}

func WithStudent(student string) LabOption {
	return func(l *Lab) {
		l.Student = student
	}
}

func WithClassID(id uint) LabOption {
	return func(l *Lab) {
		l.ClassID = id
	}
}

func WithContent(content string) LabOption {
	return func(l *Lab) {
		l.Content = content
	}
}

func WithQueue(queue string) LabOption {
	return func(l *Lab) {
		l.Queue = queue
	}
}

func WithArguments(args any) LabOption {
	return func(l *Lab) {
		l.Arguments = args
	}
}
